﻿using System.Windows;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.Prism.Regions;
using SLIP.Shells;
using SLIP.Utilities;
using ExampleModules.Views;
using ExampleModules.ViewModels;
using Microsoft.Practices.Prism.Logging;

namespace SLIP.Bootstrapper
{
    /// <summary>
    /// Main App Bootstrapper
    /// </summary>
    public class SLIPBootStrapper : UnityBootstrapper
    {
        protected override ILoggerFacade CreateLogger()
        {
            return new SLIPLogger();
        }

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            //Normally you would dynamically load assemblies and modules
            Container.RegisterType<object, ExampleView>(ModuleNames.EXAMPLEVIEW);
            Container.RegisterType<IExampleViewModel, ExampleViewModel>();
            Container.RegisterType<object, ExampleView2>(ModuleNames.EXAMPLEVIEW2);
            Container.RegisterType<IExampleViewModel2, ExampleViewModel2>();
        }

        protected override DependencyObject CreateShell()
        {
            return new SLIPLeftMenuShell();
        }

        protected override void InitializeShell()
        {
            Application.Current.RootVisual = (UIElement)Shell;

            //Load TestView in MainRegion.
            //Normally you would dynamically load assemblies and modules
            Container.Resolve<IRegionManager>().RequestNavigate(
                RegionNames.MAIN_REGION, ModuleNames.EXAMPLEVIEW);
            Container.Resolve<IRegionManager>().RequestNavigate(
                RegionNames.MAIN_REGION, ModuleNames.EXAMPLEVIEW2);
        }
    }
}
